package com.basker.pisces.core.iterate;

import java.util.List;
import java.util.Stack;

import com.basker.pisces.core.meta.IDataObjectMeta;

public class DataObjectIterateEvent {
    private List<Object> dataObjects;
    private List<Object> parentObjects;
    private IDataObjectMeta objectMeta;
    private Stack<String> iteratePath;

    public DataObjectIterateEvent(List<Object> parentObjects, List<Object> dataObjects, IDataObjectMeta objectMeta,
                                  Stack<String> iteratePath) {
        this.parentObjects = parentObjects;
        this.dataObjects = dataObjects;
        this.objectMeta = objectMeta;
        this.iteratePath = iteratePath;
    }

    public List<Object> getDataObjects() {
        return dataObjects;
    }

    public Stack<String> getIteratePath() {
        return iteratePath;
    }

    public IDataObjectMeta getObjectMeta() {
        return objectMeta;
    }

    public List<Object> getParentObjects() {
        return parentObjects;
    }

    public String getPrefix() {
        int size = iteratePath.size();
        if (size <= 1) {
            return "";
        }

        StringBuilder prefix = new StringBuilder();

        for (int i = 1; i < size; i++) {
            prefix.append(iteratePath.get(i));
            prefix.append(".");
        }

        return prefix.toString();
    }

}
